<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:spring="http://www.springframework.org/tags"
                template="../../../layout/Template.xhtml">

    <ui:define name="menu">
        <ui:include src="${user.menu}"/>
    </ui:define>

    <ui:define name="title">
        <h:outputText value="#{resourceBundle.title}"/>
    </ui:define>

    <ui:define name="content">
        <h:form id="listTraining">

            <ui:fragment id="listTrainingFragment">
                <h:messages globalOnly="true"/>

                <rich:dataTable value="#{flowScope.listTraining}"
                                var="trainingDisplayed"
                                border="1"
                                cellspacing="4"
                                width="100%"
                                id="unitDataTable"
                                rows="10">

                    <f:facet name="header">
                        <h:outputText value="#{resourceBundle.listTrainingFormHeader}"/>
                    </f:facet>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{resourceBundle.listTrainingFormName}"/>
                        </f:facet>
                        <!-- <a4j:commandLink value="#{unitDisplayed.name}" action="readUnit"/>  -->
                        <h:outputText value="#{trainingDisplayed.name}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{resourceBundle.listTrainingFormNbYEAR}"/>
                        </f:facet>
                        <h:outputText value="#{trainingDisplayed.nbYear}"/>
                    </rich:column>

                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="#{bundle.listFormAction}">
                                    <a4j:commandButton id="listUnitCreateButton"
                                                       type="submit"
                                                       image="/img/add.png"
                                                       action="createTraining"
                                                       styleClass="rightButton"
                                                       rendered="#{not user.student}">
                                        <rich:toolTip value="#{bundle.addButton}"
                                                      showDelay="600"
                                                      styleClass="tooltipButton"/>
                                    </a4j:commandButton>
                                </h:outputText>
                            </h:panelGroup>
                        </f:facet>

                        <rich:spacer width="25%" rendered="#{not user.student}"/>
                        <a4j:commandButton action="readTraining" type="submit"
                                           image="/img/consult.png"
                                           rendered="#{not user.student}">
                            <rich:toolTip value="#{bundle.consultButton}"
                                          showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>

                        <rich:spacer width="15%" rendered="#{not user.student}"/>
                        <a4j:commandButton action="updateTraining"
                                           type="submit"
                                           image="/img/edit.png"
                                           rendered="#{not user.student}">
                            <rich:toolTip value="#{bundle.updateButton}"
                                          showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>

                        <rich:spacer width="15%" rendered="#{not user.student}"/>
                        <a4j:commandButton action="deleteTraining"
                                           type="submit"
                                           image="/img/delete.png"
                                           rendered="#{not user.student}">
                            <rich:toolTip value="#{bundle.deleteButton}"
                                          showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>

                        <rich:spacer width="25%"/>
                    </rich:column>

                    <f:facet name="footer">
                        <rich:datascroller align="center" for="unitDataTable"/>
                    </f:facet>

                </rich:dataTable>
            </ui:fragment>
        </h:form>
    </ui:define>

</ui:composition>